import java.util.ArrayList;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:张熳
 * Date:2025-09-26
 * Time:14:44
 */
public class Test {
    public static void main(String[] args) {
        ArrayList<Integer> list = new ArrayList<>();//无参构造
        list.add(10);
        list.add(11);
        list.add(12);

        list.add(1,99);

        //list.clear();
        System.out.println(list);

        ArrayList<Integer> list1 = new ArrayList<>(10);//指定顺序表初始容量
        System.out.println(list1);
        ArrayList<Integer> list2 = new ArrayList<>(list);//利用其他 Collection 构建 ArrayList
        list2.add(9999);
        System.out.println(list2);
    }
    public static void main2(String[] args) {
        MyArrayList myArrayList = new MyArrayList();
        myArrayList.add(1);
        myArrayList.add(2);
        myArrayList.add(3);
        myArrayList.add(4);
        myArrayList.add(5);

        myArrayList.add(2,15);
        myArrayList.add(2,115);
        //myArrayList.add(8,99);

        myArrayList.display();

        System.out.println();

        System.out.println(myArrayList.indexOf(3));
        System.out.println(myArrayList.get(4));

        //System.out.println(myArrayList.get(10));
        myArrayList.set(2,150);
        myArrayList.display();

        System.out.println();
        myArrayList.remove(150);
        myArrayList.display();

        System.out.println();
        myArrayList.clear();
        myArrayList.display();
    }
    public static void main1(String[] args) {
        MyArrayList myArrayList = new MyArrayList();
        ILIst ilIst = new MyArrayList();

        System.out.println(ilIst.size());

        System.out.println(myArrayList.size());

        ilIst.display();
        myArrayList.display();
    }
}
